<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>AdminLTE 2 | Dashboard</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.7 -->
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/bootstrap/dist/css/bootstrap.min.css}">
    <!-- Font Awesome -->
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/font-awesome/css/font-awesome.min.css}">
    <!-- Ionicons -->
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/Ionicons/css/ionicons.min.css}">
    <!-- jvectormap -->
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/jvectormap/jquery-jvectormap.css}">
    <!-- DataTables -->
    <link rel="stylesheet" th:href="@{/adminlte/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css}">
    <!-- Theme style -->
    <link rel="stylesheet" th:href="@{/adminlte/css/AdminLTE.min.css}">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" th:href="@{/adminlte/css/skins/_all-skins.min.css}">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

    <!-- Google Font -->
    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition skin-blue sidebar-mini">
<!-- Main content -->
<section class="content">
    <!-- Info boxes -->
    <div class="row">
        <div class="col-md-3 col-sm-6 col-xs-12">
            <div class="info-box">
                <span class="info-box-icon bg-yellow"><i class="ion ion-ios-people-outline"></i></span>

                <div class="info-box-content">
                    <span class="info-box-text">用户总数</span>
                    <span class="info-box-number" th:text="${user_number}"></span>
                </div>
                <!-- /.info-box-content -->
            </div>
            <!-- /.info-box -->
        </div>
        <!-- /.col -->
        <div class="col-md-3 col-sm-6 col-xs-12">
            <div class="info-box">
                <span class="info-box-icon bg-green"><i class="ion ion-ios-cart-outline"></i></span>

                <div class="info-box-content">
                    <span class="info-box-text">订单总数</span>
                    <span class="info-box-number" th:text="${order_number}"></span>
                </div>
                <!-- /.info-box-content -->
            </div>
            <!-- /.info-box -->
        </div>
        <!-- /.col -->

        <!-- fix for small devices only -->
        <div class="clearfix visible-sm-block"></div>

        <div class="col-md-3 col-sm-6 col-xs-12">
            <div class="info-box">
                <span class="info-box-icon bg-aqua"><i class="ion ion-ios-gear-outline"></i></span>

                <div class="info-box-content">
                    <span class="info-box-text">订单总数</span>
                    <span class="info-box-number" th:text="${order_number}"></span>
                </div>
                <!-- /.info-box-content -->
            </div>
            <!-- /.info-box -->
        </div>
        <!-- /.col -->
        <div class="col-md-3 col-sm-6 col-xs-12">
            <div class="info-box">
                <span class="info-box-icon bg-red"><i class="fa fa-google-plus"></i></span>

                <div class="info-box-content">
                    <span class="info-box-text">Likes</span>
                    <span class="info-box-number">41,410</span>
                </div>
                <!-- /.info-box-content -->
            </div>
            <!-- /.info-box -->
        </div>
        <!-- /.col -->

    </div>
    <!-- /.row -->
    <div class="box">
        <div class="box-header">
            <a th:href="'/Commodity/goToAddPage?store_Id=' + ${storeId}"  class="btn btn-info">增加商品</a>
        </div>
        <div class="box-body">
            <table id="table1" class="table table-bordered table-striped">
                <thead>
                <tr>
                    <th>id</th>
                    <th>商品名</th>
                    <th>second_type_id</th>
                    <th>介绍</th>
                    <th>浏览数</th>
                    <th>搜索次数</th>
                    <th>上架日期</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="commodity : ${list}">
                    <td th:text="${commodity.id}"></td>
                    <td><a th:text="${commodity.name}" th:href="'/Specification/listCommoditySpecification?id=' + ${commodity.id}"></a></td>
                    <td th:text="${commodity.catetoryId}"></td>
                    <td th:text="${commodity.description}"></td>
                    <td th:text="${commodity.viewCount}"></td>
                    <td th:text="${commodity.searchCount}"></td>
                    <td th:text="${commodity.date}"></td>
                    <td>
                        <form th:id="${commodity.id}">
                            <input type="text" name="id" th:value="${commodity.id}" hidden="hidden" />
                            <button type="submit" th:onclick="'up('+${commodity.id}+')'">修改</button>
                            <button type="button" th:attr="onclick=|deleteCommodity(this, '${commodity.id}')|" >删除</button>
                        </form>
                    </td>
                </tr>
                </tbody>
                <tfoot>
                <tr>
                    <th>id</th>
                    <th>商品名</th>
                    <th>second_type_id</th>
                    <th>介绍</th>
                    <th>浏览数</th>
                    <th>搜索次数</th>
                    <th>上架日期</th>
                    <th>操作</th>
                </tr>
                </tfoot>
            </table>
        </div>
        <!-- /.box-body -->
    </div>
    <!-- /.box -->
</section>
<!-- /.content -->

<!-- jQuery 3 -->
<script th:src="@{/adminlte/bower_components/jquery/dist/jquery.min.js}"></script>
<!-- Bootstrap 3.3.7 -->
<script th:src="@{/adminlte/bower_components/bootstrap/dist/js/bootstrap.min.js}"></script>
<!-- FastClick -->
<script th:src="@{/adminlte/bower_components/fastclick/lib/fastclick.js}"></script>
<!-- AdminLTE App -->
<script th:src="@{/adminlte/js/adminlte.min.js}"></script>
<!-- Sparkline -->
<script th:src="@{/adminlte/bower_components/jquery-sparkline/dist/jquery.sparkline.min.js}"></script>
<!-- jvectormap  -->
<script th:src="@{/adminlte/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js}"></script>
<script th:src="@{/adminlte/plugins/jvectormap/jquery-jvectormap-world-mill-en.js}"></script>
<!-- SlimScroll -->
<script th:src="@{/adminlte/bower_components/jquery-slimscroll/jquery.slimscroll.min.js}"></script>
<!-- ChartJS -->
<script th:src="@{/adminlte/bower_components/chart.js/Chart.js}"></script>

<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<!--<script th:src="@{/adminlte/js/pages/dashboard2.js}"></script>-->

<!-- AdminLTE for demo purposes -->
<script th:src="@{/adminlte/js/demo.js}"></script>


<!-- DataTables -->
<script th:src="@{/adminlte/bower_components/datatables.net/js/jquery.dataTables.min.js}"></script>
<script th:src="@{/adminlte/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js}"></script>
<!-- SlimScroll -->
<script th:src="@{/adminlte/bower_components/jquery-slimscroll/jquery.slimscroll.min.js}"></script>
<!-- FastClick -->
<script th:src="@{/adminlte/bower_components/fastclick/lib/fastclick.js}"></script>
<!-- page script -->
<script>
    $(function () {
        $('#table1').DataTable()
    })
    function up(i) {
        document.getElementById(i).action="/Commodity/findCommodity";
        document.getElementById(i).submit();
    }
    function  deleteCommodity(elem, id) {
        $.ajax(
            {
                url: "/Commodity/deleteCommodity?id=" + id,
                type: "delete",
                success: function (data) {
                    if(data == true) {
                        $(elem).parent().parent().parent().remove();
                    } else {
                        console.log("失败");
                    }
                },
                fail: function (data) {
                    console.log(data);
                }
            }
        )
    }
</script>
</body>
</html>
